<?php
use app\models\AsrAudioClassify;
use app\models\AsrKeywordClassify;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$this->title = '';
//$this->params['breadcrumbs'][] = $this->title;

/* @var $this yii\web\View */
/* @var $model app\models\AsrAudio */
/* @var $form yii\widgets\ActiveForm */
?>
<link href="../assets/public/css/asr-audio/asr-audio.min.css" rel="stylesheet">

<link href="../assets/public/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">

<link href="../assets/public/css/create.css" rel="stylesheet">

<link href="../assets/public/css/asr-audio/main.css" rel="stylesheet">

<script src="../assets/public/js/vue.min.js"></script>

<!--<script src="../assets/public/js/asr-audio/asr-audio.min.js"></script>-->

<!--<script src="../assets/public/js/pekeUpload.min.js"></script>-->

<script src="../assets/public/js/vue-axios/axios.min.js"></script>

<header class="main-header" style="z-index:1; margin: -30px -15px;">
    <!--    话术流程导航   -->
    <nav class="navbar navbar-default " style="margin-left: 0px;background-color: #0071a6">
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse pull-left" id="navbar-collapse">
            <ul class="nav nav-pills nav-justified">
                <a style="color:white; margin: 15px;" id="back" class="pull-left" href="index?page=<?php echo isset($_GET['page'])?$_GET['page']:0; ?>&per-page=<?php echo isset($_GET['per-page'])?$_GET['per-page']:0; ?>" ><i class="fa fa-backward"></i> 返回</a>
                <li class="dropdown active" id="main-system"><a href="update?id=<?php echo $id?>&page=<?php echo isset($_GET['page'])?$_GET['page']:0; ?>&per-page=<?php echo isset($_GET['per-page'])?$_GET['per-page']:0; ?>" class="dropdown-toggle" data-toggle="dropdown">主流程</a>
                </li>
                <li class="dropdown" id="profession">
                    <a href="profession?id=<?php echo $id?>&page=<?php echo isset($_GET['page'])?$_GET['page']:0; ?>&per-page=<?php echo isset($_GET['per-page'])?$_GET['per-page']:0; ?>" class="dropdown-toggle" data-toggle="dropdown" id="profession">业务流程</a>
                </li>
                <li class="dropdown" id="system-flow">
                    <a href="system?id=<?php echo $id?>&page=<?php echo isset($_GET['page'])?$_GET['page']:0; ?>&per-page=<?php echo isset($_GET['per-page'])?$_GET['per-page']:0; ?>" class="dropdown-toggle" data-toggle="dropdown" id="system">系统流程</a>
                </li>
                <li class="dropdown" id="stop">
                    <a href="end?id=<?php echo $id?>&page=<?php echo isset($_GET['page'])?$_GET['page']:0; ?>&per-page=<?php echo isset($_GET['per-page'])?$_GET['per-page']:0; ?>" class="dropdown-toggle" data-toggle="dropdown">结束</a>
                </li>
            </ul>
        </div>
        <!-- /.container-fluid -->
    </nav>
</header>
<div id="all">
    <input type="hidden" id="id" value="<?=$id ?>">
    <div class="frame-body-box">

        <div class="frame-right-box">

            <div id="answerDetail" class="" style="display: block;margin-top: 45px">

                <div class="answerContent">

                    <div id="answerDetail" style="display: block;">
                        <div class="answerContent" style="background-color: #ffffff">
                            <div class="title">
                                <div class="titlehs"><h4 style="color: #77b5fd;margin-top: 0px;margin-bottom: 0px">话术设置</h4></div>
                            </div>
                            <div class="answerMain">
                                <div class="sonNav ansLeft" id="ansLeft">
                                    <div class="sonList">
                                        <ul id="sonLeft">
                                            <li v-for="(value, key) in list"  v-bind:class="{current:key==i}">
                                                <div class="sTit" style=""  @click="check"><p class="p" v-bind:data-key="value.keyword_classify_id" v-bind:data-k="key">{{value.name}}</p></div>
                                            </li>
                                        </ul>
                                    </div>
                                    <p class="sonAdd" @click="addNode">+ <span>添加</span></p>
                                </div>
                                <!--        <div class="" style="clear: both;"></div>-->
                                <div class="ansRight" id="asrRight">
                                    <div class="">
                                        <div class="mBox">
                                            <div class="fmBox form-inline">

                                                <div class="form-group">
                                                    <label for="exampleInputName2" style="font-weight:normal">话术节点名称：</label>
                                                    <input type="text" class="form-control" autocomplete="off" v-model="name" name="nodename" id="exampleInputName2" placeholder="">
                                                </div>

                                                <div class="form-group">
                                                    <label for="exampleInputName2" style="font-weight:normal">命中该标签意向分：</label>
                                                    <input type="text" class="form-control" name="score" autocomplete="off" id="exampleInputName2" placeholder="请输入分数" v-model="score">
                                                </div>
                                            </div>
                                            <img src="../assets/public/img/asr-audio/reflect1.png" class="reflect">
                                        </div>
                                        <div class="mBox">
                                            <div class="line" id="mainline"></div>
                                            <div style="height: 150px;" id="setting" v-for="(value, key) in content" class="setting">
                                                <div class="form-group" style="float:left;">
                                                    <lable>设置语音内容：</lable>
                                                    <textarea ref="input1" class="form-control" id="content" v-model="value.content" rows="4" style="width:300px;"></textarea>
                                                </div>
                                                <div class="audio">
                                                    <audio id="audio" controls="controls" v-bind:src="value.filepath" class="voice" style="vertical-align: -24px;"></audio>
                                                    <button :data-id="value.files_id" @click="deleteFile(value.files_id)" type="button" class="btn"><span>删除语音</span></button>
                                                </div>

                                                <div class="input-append" style="float:left;">
                                                    <form method="post" enctype="multipart/form-data">                                                               <button :id="value.files_id" @click="upload" type="button" class="el-button el-button--primary el-button--small" style="margin-left:300px;margin-top:20px;"><span :id="value.files_id"><img src="../assets/public/img/asr-audio/shangc.png" :id="value.files_id">上传语音</span>                                                               </button>                                                               <input id="upload_input" type="file" name="file" accept=".wav,.mp3" v-on:change="change(<?=$id?>,$event)" style="display:none"  value="" v-bind:index="key"  class="el-upload__input">
                                                    </form>
                                                </div>
                                            </div>

                                            <div class="btnRight">
                                                <div class="form-group" style="line-height: 40px; margin-top:20px;">
                                                    <lable style="float:left;">添加语音内容：</lable>
                                                    <div class="addAudioBtn" v-on:click="add" id="addBtn">+</div>
                                                </div>
                                            </div>
                                            <img src="../assets/public/img/asr-audio/reflect3.png" class="reflect">
                                        </div>
                                        <!--识别意向跳转,根据意向跳转,跳向话术节点-->
                                        <div class="mBox">
                                            <div class="discern">
                                                <div class="line"></div>
                                                <span class="title-left">识别意向词语：</span>
                                                <button v-for="(value,key) in result" type="button"  class="kd_cy el-button letterBtn affrim el-button--primary" @click="changeName(value.keyword_id)" style="float:left;"><span>{{value.intent_name}}</span></button>
                                            </div>

                                            <div>

                                                <div class="accord"><span class="title-left">根据意向跳转：</span>
                                                    <button v-for="(value,key) in result" type="button" @click="next(value.keyword_id)" class="kd_step el-button letterBtn nextStep el-button--primary" style="float:left;">
                                                        <span>下一步</span>
                                                    </button>
                                                </div>
                                                <div style="margin-left: 110px;" class="accords">
                                                    <button v-for="(value,key) in result" type="button" v-on:click="deleteIntent(value.keyword_id)" class="btn btn-default delkeyword"  style="width: 145px; margin-left: 8px; margin-top:20px;    border: 1px solid #dcdfe6;">
                                                        <span>删除</span></button>
                                                </div>

                                                <div class="addAudio" id="addBtn2" data-toggle="modal" data-target="#myModal"><span class="title-left">添加新的标签：</span> <div id="addFile" class="addAudioBtn">
                                                        +
                                                    </div></div>

                                            </div>
                                            <img src="../assets/public/img/asr-audio/reflect4.png" class="reflect">
                                        </div>


                                        <div class="flowBtns" style="text-align: center;">
                                            <button class="el-button el-button--primary" v-on:click="save" id="mainbtn">
                                                <span>保存</span>
                                            </button>
                                            &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
                                            <button v-if="isdel" id="maindel" class="btn btn-error" type="button" style="height: 40px;width: 160px;" @click="del">
                                                <span>删除</span>
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--                </form>-->

                    <!--隐藏的窗口弹出窗1-->
                    <div class="windowPop ployKeywords">
                        <div class="increased-form">
                            <div class="increased-title">
                                <span></span>
                                <i></i>
                            </div>
                            <div class="increased-body">
                                <div class="PopBox1">
                                    <div class="el-textarea">
                                        <textarea rows="2" id="keywordcontent" placeholder="关键字以英文半角;分开 如 你好;好" maxlength="1000" class="el-textarea__inner" v-model="keyword" style="min-height: 31px;"></textarea>
                                    </div>
                                    <label role="checkbox" class="el-checkbox">
                                    </label>
                                    <div class="flowBtns">
                                        <button type="button" class="el-button el-button--primary" id="savekeyword" @click="saveKeyword(keyword_id)"><span>保存并退出</span></button>
                                        <button type="button" @click="none" class="el-button el-button--default"><span>取消</span></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!--隐藏的窗口弹出窗2 请选择跳转话术节点-->
                    <div class="windowPop continue">
                        <div class="increased-form">
                            <div class="increased-title">

                            </div>
                            <div class="increased-body">
                                <div class="continueTitle">
                                    <ul id="ul">
                                        <li><span class="title-left">话术类型：</span>
                                            <div class="el-select">
                                                <div class="el-input el-input--suffix">
                                                    <select @change="select" v-model="selected" id="disabledSelect" class="select1 form-control" autocomplete='name'>
                                                        <option value="" style="color: #b6b6b6" disabled >请选择</option>
                                                        <option  v-for="option in options" v-bind:value="option.id">{{ option.value }}</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </li>
                                        <li><span class="title-left">话术节点：</span>
                                            <div class="el-select">
                                                <div class="el-input el-input--suffix">
                                                    <select @change="select2" id="disabledSelect" v-model="selecte" class="form-control select2" autocomplete='name'>
                                                        <option style="color: #b6b6b6" disabled value="" selected>请选择</option>
                                                        <option v-for="option in selectename" v-bind:value="option.keyword_classify_id">{{option.name}}</option>
                                                        <option v-for="option in selectenameyw" v-bind:value="option.id">{{option.name}}</option>
                                                        <option v-for="option in selectenamext" v-bind:value="option.id">{{option.name}}</option>
                                                        <option v-for="option in selectenameend" v-bind:value="option.keyword_classify_end_id">{{option.name}}</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </li>
                                        <li id="li" v-bind:style="{display:none}"><span class="title-left">话术语境：</span>
                                            <div class="el-select">
                                                <div class="el-input el-input--suffix">
                                                    <select id="disabledSelect" @change="select3" v-model="selecte3" class="form-control select3"
                                                            autocomplete="name">
                                                        <option style="color: #b6b6b6" value="" disabled>请选择</option>
                                                        <option v-for="option in sel3" v-bind:value="option.id">{{option.name}}</option>
                                                    </select></div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="flowContentBox flowBox">
                                    <div class="flowContent" v-for="(value,key) in nextfile">
                                        <span class="title-left">语音内容：</span>
                                        <div class="el-textarea is-disabled">
                                            <textarea disabled="disabled" rows="5" class="el-textarea__inner textcontent" style="min-height: 31px;" :value="value.content"></textarea>
                                        </div>
                                        <div class="audios">
                                            <div class="audio2">
                                                <audio controls="controls" :src="value.filepath" class="voice nextaudio"></audio>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="flowBtns">
                                    <button type="button" class="el-button el-button--primary savekeywordid" id="" @click="nextsave"><span>保存</span>
                                    </button>
                                    <button type="button" class="el-button el-button--warning" id="clear" @click="clear"><span>清空</span>
                                    </button>
                                    <button type="button" class="el-button nextCancel el-button--primary" @click="nextnone">
                                        <span>取消</span>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!--隐藏的窗口弹出窗3 请选择跳转话术节点-->
                    <div class="windowPop SceneSet">
                        <div class="increased-form">
                            <div class="increased-title">
                                <span>语境设置</span>
                                <i></i>
                            </div>
                            <div class="increased-body">
                                <div class="SceneBox">
                                    <div class="table SceneTable">
                                        <div class="el-table el-table--fit el-table--border el-table--scrollable-x el-table--enable-row-hover"
                                             style="width: 100%;">
                                            <div class="hidden-columns">
                                                <div></div>
                                                <div></div>
                                            </div>
                                            <div class="el-table__header-wrapper">
                                                <table cellspacing="0" cellpadding="0" border="0" class="el-table__header"
                                                       style="width: 290px;">
                                                    <colgroup>
                                                        <col name="el-table_1_column_1" width="210">
                                                        <col name="el-table_1_column_2" width="80">
                                                        <col name="gutter" width="0">
                                                    </colgroup>
                                                    <thead class="has-gutter">
                                                    <tr class="">
                                                        <th colspan="1" rowspan="1" class="el-table_1_column_1     is-leaf">
                                                            <div class="cell">语境</div>
                                                        </th>
                                                        <th colspan="1" rowspan="1" class="el-table_1_column_2     is-leaf">
                                                            <div class="cell">操作</div>
                                                        </th>
                                                        <th class="gutter" style="width: 0px; display: none;"></th>
                                                    </tr>
                                                    </thead>
                                                </table>
                                            </div>
                                            <div class="el-table__body-wrapper is-scrolling-left">
                                                <table cellspacing="0" cellpadding="0" border="0" class="el-table__body"
                                                       style="width: 290px;">
                                                    <colgroup>
                                                        <col name="el-table_1_column_1" width="210">
                                                        <col name="el-table_1_column_2" width="80">
                                                    </colgroup>
                                                    <tbody></tbody>
                                                </table>
                                                <div class="el-table__empty-block" style="width: 290px;"><span
                                                            class="el-table__empty-text">暂无数据</span></div></div>

                                            <div class="el-table__column-resize-proxy" style="display: none;"></div>
                                        </div>
                                    </div>
                                    <div class="addScen"><p>+</p></div>
                                </div>
                                <div class="flowBtns">
                                    <button type="button" class="el-button el-button--primary">
                                        <span>确定</span>
                                    </button>
                                    <button type="button" class="el-button outScenewords el-button--primary">
                                        <span>取消</span>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--添加意向-->
    <!-- Modal -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"  class="frame-body-box">
        <div class="modal-dialog frame-right-box" role="document" style="display: block;margin-top: 45px;height:0px;">
            <div id="answerDetail" class="" style="display: block;margin-top: 45px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">意向标签设置</h4>
                    </div>
                    <div class="modal-body">
                        <input type="text" class="form-control" id="intentname" placeholder="请输入名称">
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" data-dismiss="modal" v-on:click="addIntent">保存</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    // 主流程切换
    var vm = new Vue({
        el: '#all',
        data:{
            list:[],
            name:'',
            score:'',
            content:[{content:'',name:'',file_id:'',audio_id:'',filepath:''}],
            result:[],
            i:0,
            isdel:false,
            keyword:'',
            selecte: '',
            selectename:[],
            selecte3: '',
            selectename1:[],
            selectenameend:[],
            selectenameyw:[],
            selectenamext:[],
            selected: '',
            sel3:[],
            none:'none',
            options: [
                { id: '0', value: '主流程' },
                { id: '1', value: '业务流程' },
                { id: '2', value: '系统流程' },
                { id: '3', value: '结束' }
            ],
            nextfile:[{filepath:'',content:''}],
        },
        created:function () {
            this.nodename();//这里定义这个方法，vue实例之后运行到这里就调用这个函数
        },
        methods: {
            nodename:function () {
                $.ajax({
                    type:'post',
                    url:'mainpost',
                    data:{id:$('#id').val()},
                    success:function (data) {
                        var data = JSON.parse(data);
                        vm.list = data.mainSystem;
                        vm.keyword_classify_id = data.mainSystem[0].keyword_classify_id;
                        vm.name = data.mainSystem[0].name;
                        vm.score = data.score;
                        if(data.file[0] != null){
                            vm.content = data.file;
                        }
                        vm.result = data.result;
                    }
                })
            },
            check:function (event) {
                let keyword_classify_id = $(event.target).attr('data-key');
                let key = $(event.target).attr('data-k');
                if(key>0){
                    vm.isdel = true;
                }else{
                    vm.isdel = false;
                }
                $.ajax({
                    type:'post',
                    url:'mainpost',
                    data:{id:$('#id').val(),keyword_classify_id:keyword_classify_id},
                    success:function (data) {
                        var res = JSON.parse(data);
                        if(res.Result=="success"){
                            // console.log(res.Data);
                            vm.i = key;
                            vm.keyword_classify_id = res.Data.current.keyword_classify_id;
                            vm.name = res.Data.current.name;
                            vm.score = res.Data.current.intent_score;
                            if(res.Data.file[0] != null){
                                vm.content = res.Data.file;
                            }else{
                                vm.content = [{content:'',name:'',file_id:'',audio_id:'',filepath:''}];
                            }
                            vm.result = res.Data.result;
                        }else{
                            alert('切换失败');
                        }
                    }
                })

            },
            //意向删除
            deleteIntent:function (id) {
                $.ajax({
                    type:'post',
                    url:'delintentname',
                    data:{'keyword_id':id,'keyword_classify_id':vm.keyword_classify_id},
                    success:function (data) {
                        var res = JSON.parse(data);
                        if(res.Result=="success"){
                            vm.result = res.Data;
                            alert('删除成功');
                        }else{
                            alert('删除失败');
                        }
                    }
                })
            },
            upload: function (e) {
                file_id = e.target.id
                $('#upload_input').trigger('click');
            },
            //文件上传
            change: function (audio_id) {
                var index = parseInt($(event.target).attr("index"));
                var upath = event.target.files[index];
                var zipFormData = new FormData();
                zipFormData.append('filename', upath);
                zipFormData.append('file_id', file_id);
                zipFormData.append('audio_id', audio_id);
                zipFormData.append('keyword_classify_id', vm.keyword_classify_id);
                $.ajax({
                    type:'post',
                    url:'mainupload',
                    cache:false,
                    processData: false,
                    contentType : false,
                    data:zipFormData,
                    success:function (data) {
                        var res = JSON.parse(data);
                        if(res.Result=="success"){
                            vm.content = res.Data;
                            alert('上传成功');
                        }else{
                            alert('删除失败');
                        }
                    }
                });
            },
            //保存
            save:function () {
                let all = [];
                for(let i=0; i<this.$refs.input1.length;i++){
                    all[i] = this.$refs.input1[i].value;
                }
                $.ajax({
                    type:'post',
                    url:'saveclassify',
                    data:{'id':$('#id').val(),'keyword_classify_ids':vm.keyword_classify_id,'name':vm.name,'score':vm.score,'content':all},
                    success:function (data) {
                        var res = JSON.parse(data);
                        if(res.Result=="success"){
                            // console.log(res.Data);
                            vm.list = res.Data.mainSystem;
                            vm.keyword_classify_id = res.Data.current.keyword_classify_id;
                            vm.name = res.Data.current.name;
                            vm.score = res.Data.current.intent_score;
                            if(res.Data.file[0] != null){
                                vm.content = res.Data.file;
                            }else{
                                vm.content = [{content:'',name:'',file_id:'',audio_id:'',filepath:''}];
                            }
                            vm.result = res.Data.result;
                            alert('保存成功');
                        }else{
                            alert('保存失败');
                        }
                    }
                })
            },
            //删除
            del:function(){
                $.ajax({
                    type:'post',
                    url:'del',
                    data:{keyword_classify_id:vm.keyword_classify_id},
                    success:function (data) {
                        if(data==1){
                            location.reload();
                            alert('删除成功');
                        }else{
                            alert('删除失败');
                        }
                    }
                })
            },
            //删除语音
            deleteFile: function (file_id){
                $.ajax({
                    type:'post',
                    url:'maindelete',
                    data:{'file_id':file_id,'keyword_classify_id':vm.keyword_classify_id},
                    success:function (data) {
                        var res = JSON.parse(data);
                        if(res.Result=="success"){
                            // console.log(res.Data)
                            if(res.Data[0] != null){
                                vm.content = res.Data;
                            }else{
                                vm.content = [{content:'',name:'',file_id:'',audio_id:'',filepath:''}];
                                console.log(vm.content);
                            }
                            alert('删除成功');
                        }else{
                            alert('删除失败');
                        }
                    }
                })

            },
            //添加意向标签
            add: function () {
                vm.content.push({content:null,name:null,file_id:null,audio_id:null,filepath:null});
            },
            addIntent: function () {
                $.ajax({
                    type:'post',
                    url:'addintentname',
                    data:{'keyword_classify_id':vm.keyword_classify_id,'intent_name':$('#intentname').val()},
                    success:function (data) {
                        var res = JSON.parse(data);
                        if(res.Result=="success"){
                            vm.result = res.Data;
                            alert('添加成功');

                        }else{
                            alert('删除失败');
                        }
                    }
                })
            },
            addNode: function () {
                $.ajax({
                    type:'post',
                    url:'add',
                    data:{id:$('#id').val()},
                    success:function (data) {
                        var res = JSON.parse(data);
                        if(res.Result=="success"){
                            vm.list = res.Data;
                            alert('添加成功');
                        }else{
                            alert('添加失败');
                        }
                    }
                })
            },
            changeName: function (keyword_id) {
                $(".ployKeywords").css('display','block');
                vm.keyword_id = keyword_id;
                $(".ployKeywords .increased-title span").html("关键字");
                $.ajax({
                    type:'post',
                    url:'searchkeyword',
                    data:{'keyword_id':keyword_id},
                    success:function (data) {
                        vm.keyword = data;
                    }
                });
            },
            saveKeyword: function(keyword_id){
                $.ajax({
                    type:'post',
                    url:'mainkeyword',
                    data:{'keyword_id':keyword_id,'content':$('#keywordcontent').val(),'main_keyword_classify':vm.keyword_classify_id},
                    success:function (data) {
                        if(data==1){
                            alert('保存成功');
                            $(".ployKeywords").css('display','none');
                        }else{
                            alert('保存失败');
                        }
                    }
                });

            },
            next: function (keyword_id) {
                $(".continue").css('display','block');
                $(".continue .increased-title span").html("请选择检测到“肯定词语”后跳转到的话术节点");
                vm.keyword_id = keyword_id;
                $.ajax({
                    type:'post',
                    url:'maincontents',
                    data:{keyword_id:vm.keyword_id,audio_id:$('#id').val()},
                    success:function (data) {
                        var res = JSON.parse(data);
                        if(res.Result=="success"){
                            console.log(res);
                            if(res.Data.next_classify_type==0){
                                vm.none = 'none';
                                vm.selectename = res.Data.nodename;
                            }else if(res.Data.next_classify_type==1){
                                vm.none = 'block';
                                vm.selectenameyw = res.Data.nodename;
                                vm.sel3 = res.Data.ywlc;
                                vm.selecte3 = res.Data.select3;
                            }else if(res.Data.next_classify_type==2){
                                vm.none = 'none';
                                vm.selectenamext = res.Data.nodename;
                            }else if(res.Data.next_classify_type==3){
                                vm.none = 'none';
                                vm.selectenameend = res.Data.nodename;
                            }
                            vm.selected = res.Data.next_classify_type;
                            vm.selecte = res.Data.keyword_classify_id;
                            // console.log(vm.selecte);
                            vm.nextfile = res.Data.file;
                        }else{
                            vm.selectename = [];
                            vm.selected = '';
                            vm.selecte = '';
                            vm.nextfile = [{filepath:'',content:''}];
                        }
                    }
                })
            },
            select: function(){
                $.ajax({
                    type:'post',
                    url:'savenext',
                    data:{keyword_id:vm.keyword_id,selected:vm.selected,audio_id:$('#id').val()},
                    success:function (data) {
                        var res = JSON.parse(data);
                        // console.log(res.node);
                        if(vm.selected==0){
                            vm.none = 'none';
                            vm.selectenameend = [];
                            vm.selectenamext = [];
                            vm.selectenameyw = [];
                            vm.selectename = res.node;
                            vm.nextfile = [{filepath:'',content:''}];
                        }else if(vm.selected==1){
                            vm.selectenameend = [];
                            vm.selectenamext = [];
                            vm.selectename = [];
                            vm.selectenameyw = res.node;
                            vm.nextfile = [{filepath:'',content:''}];
                        }else if(vm.selected==2){
                            vm.none = 'none';
                            vm.selectenameend = [];
                            vm.selectename = [];
                            vm.selectenameyw = [];
                            vm.selectenamext = res.node;
                            vm.nextfile = [{filepath:'',content:''}];
                        }else if(vm.selected==3){
                            vm.none = 'none';
                            vm.selectename = [];
                            vm.selectenamext = [];
                            vm.selectenameyw = [];
                            vm.selectenameend = res.node;
                            vm.nextfile = [{filepath:'',content:''}];
                        }
                    }
                })
            },
            select2: function(){
                $.ajax({
                    type:'post',
                    url:'twoselect',
                    data:{select:vm.selected,classify_id:vm.selecte},
                    success:function (data) {
                        var res = JSON.parse(data);
                        if(vm.selected==1){
                            vm.none = 'block';
                            vm.sel3 = res.ywlc;
                            vm.nextfile = [{filepath:'',content:''}];
                        }else{
                            if(res.Result=="success"){
                                // console.log(res);
                                vm.nextfile = res.Data.file;
                            }else{
                                vm.nextfile = [{filepath:'',content:''}];
                            }
                        }
                    }
                })
            },
            select3: function(){
                $.ajax({
                    type:'post',
                    url:'threeselect',
                    data:{classify_id:vm.selecte3},
                    success:function (data) {
                        var res = JSON.parse(data);
                        if(res.Result=="success"){
                            vm.none = 'block';
                            console.log(res);
                            vm.none = 'block';
                            vm.nextfile = res.Data.file;
                        }else{
                            vm.nextfile = [{filepath:'',content:''}];
                        }
                    }
                })
            },
            none: function () {
                $(".ployKeywords").css('display','none');
            },
            clear: function () {
                $.ajax({
                    type:'post',
                    url:'delselect',
                    data:{'keyword_id':vm.keyword_id},
                    success:function (data) {
                        if(data==1){
                            alert('清空成功');
                            $(".continue").css('display','none');
                        }else{
                            alert('清空失败')
                        }
                    }
                })
            },
            nextnone:function () {
                $(".continue").css('display','none');
            },
            nextsave: function () {
                if(vm.selected == 1){
                    $.ajax({
                        type:'post',
                        url:'saveselect',
                        data:{'select1':vm.selected,'select2':vm.selecte,'select3':vm.selecte3,'keyword_id':vm.keyword_id},
                        success:function (data) {
                            if(data==1){
                                alert('保存成功');
                                $(".continue").css('display','none');
                            }else{
                                alert('保存失败')
                            }
                        }
                    })
                }else{
                    $.ajax({
                        type:'post',
                        url:'saveselect',
                        data:{'select1':vm.selected,'select2':vm.selecte,'select3':vm.selecte3,'keyword_id':vm.keyword_id},
                        success:function (data) {
                            if(data==1){
                                alert('保存成功');
                                $(".continue").css('display','none');
                            }else{
                                alert('保存失败')
                            }
                        }
                    })
                }
            }
        }
    })

</script>
<script>

    //切换导航
    $('#navbar-collapse ul li').click(function () {
        $('#navbar-collapse ul li').removeClass('active');
        $(this).addClass('active');
        var href = $(this).children()[0].href
        location.href = href;
    });
</script>